package io.mybatis.example.springboot.controller;

import io.mybatis.common.core.DataResponse;
import io.mybatis.common.core.RowsResponse;

import io.mybatis.example.springboot.model.QrtzPausedTriggerGrps;
import io.mybatis.example.springboot.service.QrtzPausedTriggerGrpsService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * QRTZ_PAUSED_TRIGGER_GRPS - 暂停的触发器表
 *
 * @author mkj
 */
@RestController
@RequestMapping("qrtzPausedTriggerGrpses")
public class QrtzPausedTriggerGrpsController {

  @Autowired
  private QrtzPausedTriggerGrpsService qrtzPausedTriggerGrpsService;

  @PostMapping
  public DataResponse<QrtzPausedTriggerGrpsDO> save(@RequestBody QrtzPausedTriggerGrpsDO qrtzPausedTriggerGrps) {
    return DataResponse.ok(qrtzPausedTriggerGrpsService.save( qrtzPausedTriggerGrps));
  }

  @GetMapping
  public RowsResponse<QrtzPausedTriggerGrpsDO> findList(@RequestBody QrtzPausedTriggerGrpsDO qrtzPausedTriggerGrps) {
    return RowsResponse.ok(qrtzPausedTriggerGrpsService.findList( qrtzPausedTriggerGrps));
  }

  @GetMapping(value = "/{id}")
  public DataResponse<QrtzPausedTriggerGrpsDO> findById(@PathVariable("id") Long id) {
    return DataResponse.ok(qrtzPausedTriggerGrpsService.findById(id));
  }

  @PutMapping(value = "/{id}")
  public DataResponse<QrtzPausedTriggerGrpsDO> update(@PathVariable("id") Long id, @RequestBody QrtzPausedTriggerGrpsDO qrtzPausedTriggerGrps) {
    qrtzPausedTriggerGrps.setId(id);
    return DataResponse.ok(qrtzPausedTriggerGrpsService.update( qrtzPausedTriggerGrps));
  }

  @DeleteMapping(value = "/{id}")
  public DataResponse<Boolean> deleteById(@PathVariable("id") Long id) {
    return DataResponse.ok(qrtzPausedTriggerGrpsService.deleteById(id) == 1);
  }

}
